home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / ClipEdMenu.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  25.7 KB  |  898 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Nov 1999
  22. //  Author:            Kevin Smith
  23. //
  24. //  Description:
  25. //        This script builds the pulldown and popup menus for the TraX
  26. //        editor.
  27. //
  28. //  Input Arguments:
  29. //        None.
  30. //
  31. //  Return Value:
  32. //        None.
  33. //
  34. //  Note:
  35. //        None.
  36. // 
  37.  
  38. global int $currentCharacterState = 0;
  39.  
  40. global proc buildClipEditorFileMenu (string $editor, string $parent)
  41. {    
  42.     setParent -menu $parent;
  43.     if (`menu -query -numberOfItems $parent` != 0) return;
  44.  
  45.     menuItem -label "Import Clip..."
  46.         -annotation "Open Clip From Disk."
  47.         -command ("doImportClipArgList(\"2\",{\"0\"})")
  48.         openClipItem;    
  49.  
  50.     menuItem -label "Import Clip to Characters..."
  51.         -annotation "Open Clip from Disk onto Selected Character Sets."
  52.         -command ("performImportClipToChar 0")
  53.         -dragMenuCommand ("performImportClipToChar 2")
  54.         openClipToCharItem;    
  55.     menuItem -optionBox true
  56.         -annotation "Import Clip To Character Option Box"
  57.         -label "Import Clip To Character Option Box"
  58.         -command ("performImportClipToChar 1")
  59.         openClipToCharOBItem;
  60.  
  61.     string $exportEdCmd = ("doExportClipArgList 1 {\\\""+$editor+"\\\"}");
  62.     menuItem -label "Export Clip..."
  63.         -annotation "Save Clip to Disk: Select clip"
  64.         -command ("evalEcho(\""+$exportEdCmd+"\")")
  65.         SaveClipItem;                
  66.  
  67.     menuItem -label "Export Character Map..."
  68.         -annotation "Write Character Map Mel Script to Disk: Select 2 character sets. Then modify and execute the mel script to create a character map."
  69.         -dragMenuCommand ("performExportCharacterMap 2")
  70.         -command ("performExportCharacterMap 0")
  71.         SaveCharacterMapItem;                
  72.     menuItem -optionBox true
  73.         -annotation "Export Character Map Option Box"
  74.         -label "Export Character Map Option Box"
  75.         -command ("performExportCharacterMap 1")
  76.         SaveCharacterMapDialogItem;
  77.  
  78.     menuItem -divider true;
  79.  
  80.     menuItem -label "Visor..."
  81.         -enable 1
  82.         -annotation "Open Visor Window."
  83.         -command  ("VisorWindow") 
  84.         //-dragMenuCommand("foo")
  85.         openLibClipItem;
  86. }
  87.  
  88. global proc buildClipEditorCreateMenu (string $editor, string $parent)
  89. {    
  90.     setParent -menu $parent;
  91.     if (`menu -query -numberOfItems $parent` != 0) return;
  92.  
  93.     menuItem -label "Clip"
  94.         -annotation "Create Clip: Select character set"
  95.         -command ("CreateClip") 
  96.         -dragMenuCommand("performCreateClip 2")
  97.         createClipItem;
  98.     menuItem -optionBox true
  99.         -annotation "Create Clip Option Box"
  100.         -label "Create Clip Option Box"
  101.         -command ("performCreateClip 1") 
  102.         createClipDialogItem;
  103.  
  104.     menuItem -label "Pose"
  105.         -annotation "Create Pose: Select character set"
  106.         -command ("performCreatePose 0")         
  107.         -dragMenuCommand("performCreatePose 2")
  108.         createPoseItem;
  109.     menuItem -optionBox true
  110.         -annotation "Create Pose Option Box"
  111.         -label "Create Pose Option Box"
  112.         -command ("performCreatePose 1") 
  113.         createPoseDialogItem;
  114.  
  115.     menuItem -label "Blend"
  116.         -annotation "Blend Clips: select two clips"
  117.         -command ("performBlendClip 0 " + $editor)
  118.         -dragMenuCommand("performBlendClip 2 " + $editor)
  119.         blendClipsItem;
  120.     menuItem -optionBox true
  121.         -annotation "Blend Clips Option Box"
  122.         -label "Blend Option Box"
  123.         -command ("performBlendClip 1 " + $editor)
  124.         blendClipsDialogItem;
  125.  
  126.     menuItem -l "Character Set" 
  127.         -annotation "Create: Create a character set"
  128.         -c "CreateCharacter" 
  129.         -dragMenuCommand "performCreateCharacter 2" 
  130.         createCharacterItem;
  131.         menuItem -optionBox true
  132.             -annotation "Create Character Set Option Box"
  133.             -l "Create Character Set Option Box"
  134.             -c "performCreateCharacter 1"
  135.             createCharacterDialogItem; 
  136.  
  137.     menuItem -l "Time Warp"
  138.         -annotation "Create Time Warp: select a clip"
  139.         -command ("performCreateClipTimeWarp 0 " + $editor)
  140.         -dragMenuCommand  ("performCreateClipTimeWarp 2" + $editor)
  141.         createClipTimeWarpItem;
  142.         menuItem -optionBox true
  143.             -annotation "Create Time Warp Option Box"
  144.             -l "Create Time Warp Option Box"
  145.             -c ("performCreateClipTimeWarp 1 " + $editor)
  146.             createClipTimeWarpDialogItem;
  147. }
  148.  
  149. global proc buildClipEditorEditMenu (string $editor, string $parent)
  150. {    
  151.     int $dimWhenNoSelect = 0;
  152.     setParent -menu $parent;
  153.  
  154.     if (`menu -query -numberOfItems $parent` != 0) return;
  155.  
  156.     menuItem -label "Undo" 
  157.         -ecr false
  158.         -annotation "Undo: Undo the last action"
  159.         -command ("Undo") undoItem;
  160.     if( $dimWhenNoSelect )
  161.         dimWhen -f "UndoAvailable" ($parent+"|undoItem");
  162.  
  163.     menuItem -label "Redo"
  164.         -ecr false
  165.         -annotation "Redo: Redo the last undone action"
  166.         -command ("Redo") redoItem;
  167.     if( $dimWhenNoSelect )
  168.         dimWhen -f "RedoAvailable" ($parent+"|redoItem");
  169.  
  170.     menuItem -divider true;
  171.  
  172.     string $removeCmd = "doCutClipArgList 1 { \""+ $editor+"\" }";
  173.     menuItem -label "Cut"
  174.         -annotation "Cut Selection: Select Clip|<other object(s)>"
  175.         -command $removeCmd
  176.         -dragMenuCommand $removeCmd;
  177.  
  178.     string $copyCmd = "doCopyClipArgList 1 { \""+ $editor+"\" }";
  179.     menuItem -label "Copy"
  180.         -annotation "Copy Clip: Select Clip"
  181.         -command $copyCmd
  182.         -dragMenuCommand $copyCmd;
  183.  
  184.     menuItem -label "Paste"
  185.         -annotation "Paste Selection: Select Character Set"
  186.         -command ("performPasteClip 0")
  187.         -dragMenuCommand ("performPasteClip 2");
  188.  
  189.     menuItem -optionBox true
  190.         -annotation "Paste Clip Option Box"
  191.         -label "Paste Option Box"
  192.         -command ("performPasteClip 1") 
  193.         pasteClipDialogItem;
  194.  
  195.     menuItem -divider true;
  196.  
  197.     string $splitString = ("performSplitClip 1 \\\""+$editor+"\\\"");    
  198.     string $splitCmd = ("evalEcho(\""+$splitString+"\")");
  199.     menuItem -label "Split"
  200.         -annotation "Split Clip: Select clip"
  201.         -command ("performSplitClip 0 "+$editor)
  202.         splitClipItem;
  203.     menuItem -optionBox true
  204.         -annotation "Split Clip Option Box"
  205.         -label "Split Clip Option Box"
  206.         -command $splitCmd
  207.         splitClipDialogItem;
  208.  
  209.     menuItem -label "Merge"
  210.         -annotation "Merge Clips: Select the clip(s) to merge."
  211.         -command ("performBakeClip 0 " + $editor)
  212.         -dragMenuCommand("performBakeClip 2 " + $editor)
  213.         bakeClipsItem;
  214.     menuItem -optionBox true
  215.         -annotation "Merge Clips Option Box"
  216.         -label "Merge Option Box"
  217.         -command ("performBakeClip 1 " + $editor)
  218.         bakeClipsDialogItem;
  219.         
  220.     menuItem -divider true;
  221.  
  222.     menuItem -label "Duplicate"
  223.         -annotation "Duplicate Clip (copy animation curves): Select clip"
  224.         -command ("performDuplicateClip 0 "+$editor) 
  225.         -dragMenuCommand ("performDuplicateClip 2 "+$editor)
  226.         duplicateClipItem;
  227.     menuItem -optionBox true
  228.         -annotation "Duplicate Option Box"
  229.         -label "Duplicate Option Box"
  230.         -command ("performDuplicateClip 1 "+$editor) 
  231.         duplicateClipDialogItem;
  232.  
  233.     menuItem -label "Instance"
  234.         -annotation "Instance (share animation curve with original): Select clip"
  235.         -command ("performInstanceClip 0 " + $editor) 
  236.         -dragMenuCommand("performInstanceClip 2 " + $editor)
  237.         instanceClipItem;
  238.     menuItem -optionBox true
  239.         -annotation "Instance Clip Option Box"
  240.         -label "Instance Clip Option Box"
  241.         -command ("performInstanceClip 1 " + $editor)
  242.         instanceClipDialogItem;
  243. }
  244.  
  245. global proc buildClipEditorLibraryMenu (string $editor, string $parent)
  246. {    
  247.     int $dimWhenNoSelect = 0;
  248.     setParent -menu $parent;
  249.  
  250.     if (`menu -query -numberOfItems $parent` != 0) return;
  251.  
  252.     menuItem -l "Insert Clip" -sm true -aob 1 insertLibraryClipItem;
  253.     menu -e -pmc "createClipLibraryMenu clip insertLibraryClipItem"
  254.         insertLibraryClipItem;
  255.     setParent -m ..;
  256.     
  257.     menuItem -l "Insert Pose" -sm true -aob 1 insertLibraryPoseItem;
  258.     menu -e -pmc "createClipLibraryMenu pose insertLibraryPoseItem"
  259.         insertLibraryPoseItem;
  260.     setParent -m ..;
  261. }
  262.  
  263. global proc frameTimelineRange (string $editor)
  264. {
  265.     float $start, $end;
  266.     $start     = `playbackOptions -q -min`;
  267.     $end    = `playbackOptions -q -max`;
  268.     clipEditor -e -fr $start $end $editor;
  269. }
  270.  
  271. global proc selectSourceClip(string $editor)
  272. {
  273.     string $sourceClips;
  274.     string $selectedClips[] = `clipEditor -q -sc $editor`;
  275.  
  276.     int $ii;
  277.     for ($ii = 0; $ii < size($selectedClips); $ii += 2) {
  278.         int $clipIndex =  $selectedClips[$ii+1];
  279.         string $sch = $selectedClips[$ii];
  280.         string $clipName = `clipSchedule -ci $clipIndex -q -n $sch`;
  281.         string $sourceClip = `clip -q -scn $clipName`;
  282.         $sourceClips += ($sourceClip+" ");
  283.     }
  284.  
  285.     $cmd = ("select -r "+$sourceClips);
  286.     evalEcho $cmd;
  287. }
  288.  
  289. //
  290. // This method is called from the clipEditor command when the display
  291. // state of the editor changes.
  292. //
  293. global proc setCurrentCharacterList (string $editor, int $state)
  294. {
  295.     global int $currentCharacterState;
  296.     string $popupMenuName   = ($editor + "PopupMenu");
  297.     string $currentListItem = ($editor + "currentListItem");
  298.  
  299.     // If the menu has not been created, do nothing.
  300.     if (!`popupMenu -exists $popupMenuName`)
  301.         return;
  302.         
  303.     // Set the menuItem state.
  304.     menuItem -e -cb $state $currentListItem;
  305.     $currentCharacterState = $state;
  306. }
  307.  
  308. // 
  309. // This method is called from the menu item when the "List Current Characters"
  310. // item is selected.
  311. //
  312. global proc toggleCurrentCharacterList (string $curMenuItem, string $editor)
  313. {
  314.     if (`menuItem -q -checkBox $curMenuItem`)
  315.         clipEditor -e -listCurrentCharacters $editor;
  316.     else
  317.         clipEditor -e -listAllCharacters $editor;
  318. }
  319.  
  320. global proc buildClipEditorViewMenu (string $editor, string $parent)
  321. {    
  322.     global int $currentCharacterState;
  323.     
  324.     setParent -menu $parent;
  325.     
  326.     // Make sure the current character toggle is up to date.
  327.     
  328.     if (`menu -query -numberOfItems $parent` != 0) {
  329.         setCurrentCharacterList($editor, $currentCharacterState);
  330.         return;
  331.     }
  332.     
  333.     string $currentListItem = ($editor + "currentListItem");
  334.     menuItem -label "List Current Character Sets Only"
  335.         -checkBox 0
  336.         -enable 1
  337.         -command ("toggleCurrentCharacterList " + $currentListItem + " " + $editor)
  338.         -annotation "List only the current character sets in the scene."
  339.         $currentListItem;
  340.     setCurrentCharacterList($editor, $currentCharacterState);
  341.         
  342.     menuItem -label "Frame All"
  343.         -enable 1
  344.         -annotation "Frame All Clips."
  345.         -command ("FrameAll")
  346.         frameAllItem;
  347.  
  348.     menuItem -label "Frame Timeline Range" 
  349.         -enable 1
  350.         -annotation "Frame current timeline range."
  351.         -command ("frameTimelineRange " + $editor)
  352.         frameTimelineItem;
  353.  
  354.     menuItem -divider true;
  355.  
  356.     menuItem -label "Graph Anim Curves..."
  357.         -enable 1
  358.         -annotation "Graph Clip Animation Curves: Select clip"
  359.         -command ("clipGraphEditor "+$editor)
  360.         graphCurvesClipItem;
  361. }
  362.  
  363. global proc buildClipEditorOptionsMenu (string $editor, string $parent)
  364. {
  365.     string $traxRadioSmallName = ($editor + "TraxRadioSmallName");
  366.     string $traxRadioLargeName = ($editor + "TraxRadioLargeName");
  367.     
  368.     setParent -menu $parent;
  369.     if (`menu -query -numberOfItems $parent` != 0)
  370.         return;
  371.  
  372.     radioMenuItemCollection;
  373.     menuItem     -label "Small Track Height"
  374.                 -rb 1
  375.                 -command "clipEditor -allTrackHeights 1"
  376.                 $traxRadioSmallName;
  377.     menuItem     -label "Large Track Height"
  378.                 -rb 1
  379.                 -command "clipEditor -allTrackHeights 2"
  380.                 $traxRadioLargeName;
  381.         
  382.     if (!`optionVar -exists traxEditorTrackHeight`)
  383.         optionVar -iv traxEditorTrackHeight 1;
  384.     
  385.     if (`optionVar -q traxEditorTrackHeight` == 1) {
  386.         menuItem -e -rb 1 $traxRadioSmallName;
  387.         menuItem -e -rb 0 $traxRadioLargeName;
  388.     }
  389.     else {
  390.         menuItem -e -rb 0 $traxRadioSmallName;
  391.         menuItem -e -rb 1 $traxRadioLargeName;
  392.     }
  393. }
  394.  
  395. global proc buildClipEditorClipMenu (string $editor, string $parent)
  396. {    
  397.     setParent -menu $parent;
  398.     if (`menu -query -numberOfItems $parent` != 0) return;
  399.  
  400.     menuItem -label "Attribute Editor..."
  401.         -annotation "Attribute Editor: Edit clips"
  402.         -command ("clipPropertiesWindow "+$editor)
  403.         -dragMenuCommand ("clipPropertiesWindow "+$editor)
  404.         clipPropItem;
  405.  
  406.     menuItem -divider true;
  407.  
  408.     string $enableCmd = "doEnableClipArgList 1 { \""+
  409.         $editor+"\",\"2\"}";
  410.     menuItem -label "Enable/Disable"
  411.         -annotation "Enable or Disable Clip: Select clip"
  412.         -command $enableCmd
  413.         -dragMenuCommand $enableCmd
  414.         enableClipItem;
  415.  
  416.     string $activateCmd = "doActivateClipArgList 1 { \""+
  417.         $editor+"\",\"2\"}";
  418.     menuItem -label "Activate/Deactivate Keys"
  419.         -annotation "Activate or Dectivate Clip Keys (Move Keys to Timeline): Select clip"
  420.         -command $activateCmd
  421.         -dragMenuCommand $activateCmd
  422.         activateClipItem;
  423.  
  424.     menuItem -divider true;
  425.  
  426.     menuItem -label "Add Track"
  427.         -annotation "Add track to selected character set"
  428.         -command ("clip -at") 
  429.         addTrackItem;
  430.         
  431.     menuItem -label "Remove Track"
  432.         -annotation "Remove last unused track from selected character set"
  433.         -command ("clip -rt") 
  434.         removeTrackItem;
  435.  
  436. }
  437.  
  438. global proc buildClipMainPopupMenuItems(string $editor, string $menuName, 
  439.                                     string $collectionName) 
  440. {
  441.     setParent -m $menuName;
  442.     
  443.     if (`menu -query -numberOfItems $menuName` != 0) return;
  444.  
  445.     string $menuItem = `menuItem -l "File" 
  446.         -subMenu true
  447.         -allowOptionBoxes true
  448.         FileCascade`;
  449.  
  450.     menuItem -edit -postMenuCommand 
  451.         ("buildClipEditorFileMenu " + $editor + " " + $menuItem) $menuItem;
  452.     setParent -menu ..;
  453.  
  454.     string $menuItem = `menuItem -l "Edit" 
  455.         -subMenu true
  456.         -allowOptionBoxes true
  457.         EditCascade`;
  458.  
  459.     menuItem -edit -postMenuCommand 
  460.         ("buildClipEditorEditMenu " + $editor + " " + $menuItem) $menuItem;
  461.     setParent -menu ..;
  462.  
  463.     string $menuItem = `menuItem -l "View" 
  464.         -subMenu true 
  465.         -allowOptionBoxes true
  466.         ViewCascade`;
  467.  
  468.     menuItem -edit -postMenuCommand 
  469.         ("buildClipEditorViewMenu " + $editor + " " + $menuItem) $menuItem;
  470.     setParent -menu ..;
  471.  
  472.     string $menuItem = `menuItem -l "Modify" 
  473.         -subMenu true
  474.         -allowOptionBoxes true
  475.         ModifyCascade`;
  476.  
  477.     menuItem -edit -postMenuCommand 
  478.         ("buildClipEditorClipMenu " + $editor + " " + $menuItem) $menuItem;
  479.     setParent -menu ..;
  480.  
  481.     string $menuItem = `menuItem -l "Create" 
  482.         -subMenu true 
  483.         -allowOptionBoxes true
  484.         CreateCascade`;
  485.  
  486.     menuItem -edit -postMenuCommand 
  487.         ("buildClipEditorCreateMenu " + $editor + " " + $menuItem) $menuItem;
  488.     setParent -menu ..;
  489.  
  490.     string $menuItem = `menuItem -l "Options" 
  491.         -subMenu true 
  492.         -allowOptionBoxes true
  493.         OptionsCascade`;
  494.  
  495.     menuItem -edit -postMenuCommand 
  496.         ("buildClipEditorOptionsMenu " + $editor + " " + $menuItem) $menuItem;
  497.     setParent -menu ..;
  498.  
  499.     string $menuItem = `menuItem -l "Library"
  500.         -subMenu true 
  501.         -allowOptionBoxes true
  502.         LibraryCascade`;
  503.  
  504.     menuItem -edit -postMenuCommand 
  505.         ("buildClipEditorLibraryMenu " + $editor + " " + $menuItem) $menuItem;
  506.     setParent -menu ..;
  507. }
  508.  
  509.  
  510. global proc buildClipEditorMenu(string $editor, string $parent, 
  511.                                 string $collectionName)
  512. {
  513.     string $menu = `menu -l "File" -to true
  514.         -familyImage "menuIconEdit.xpm"
  515.         -allowOptionBoxes true`;
  516.  
  517.     menu -edit -postMenuCommand 
  518.         ("buildClipEditorFileMenu " + $editor + " " + $menu) $menu;
  519.     setParent -menu ..;
  520.  
  521.     string $menu = `menu -l "Edit"  -to true
  522.         -familyImage "menuIconEdit.xpm"
  523.         -allowOptionBoxes true`;
  524.  
  525.     menu -edit -postMenuCommand 
  526.         ("buildClipEditorEditMenu " + $editor + " " + $menu) $menu;
  527.     setParent -menu ..;
  528.  
  529.     string $menu = `menu -l "View"  -to true
  530.         -allowOptionBoxes true
  531.         -familyImage "menuIconEdit.xpm"`;
  532.  
  533.     menu -edit -postMenuCommand 
  534.         ("buildClipEditorViewMenu " + $editor + " " + $menu) $menu;
  535.     setParent -menu ..;
  536.  
  537.     string $menu = `menu -l "Modify"  -to true
  538.         -allowOptionBoxes true
  539.         -familyImage "menuIconEdit.xpm"`;
  540.  
  541.     menu -edit -postMenuCommand 
  542.         ("buildClipEditorClipMenu " + $editor + " " + $menu) $menu;
  543.     setParent -menu ..;
  544.  
  545.     string $menu = `menu -l "Create"  -to true
  546.         -allowOptionBoxes true
  547.         -familyImage "menuIconEdit.xpm"`;
  548.  
  549.     menu -edit -postMenuCommand 
  550.         ("buildClipEditorCreateMenu " + $editor + " " + $menu) $menu;
  551.     setParent -menu ..;
  552.  
  553.     string $menu = `menu -l "Options"  -to true
  554.         -allowOptionBoxes true`;
  555.  
  556.     menu -edit -postMenuCommand 
  557.         ("buildClipEditorOptionsMenu " + $editor + " " + $menu) $menu;
  558.     setParent -menu ..;
  559.  
  560.     string $menu = `menu -l "Library"  -to true
  561.         -familyImage "menuIconEdit.xpm"
  562.         -allowOptionBoxes true`;
  563.  
  564.     menu -edit -postMenuCommand 
  565.         ("buildClipEditorLibraryMenu " + $editor + " " + $menu) $menu;
  566.     setParent -menu ..;
  567. }
  568.  
  569. global proc buildClipMenuItems(string $editor, string $menu)
  570. {
  571.     setParent -m $menu;
  572.  
  573.     // Determine the status of the selected clips: enable, relative, active
  574.     //
  575.     int $ii;
  576.     int $enableState; // 0 == all off, 1 == all on, 2 == mixed
  577.     int $activeState; // 0 == all inactive, 1 == all active, 2 == mixed
  578.     int $absState; // 0 == all relative, 1 == all absolute, 2 == mixed    
  579.     string $selClips[] = `clipEditor -q -sc $editor`;
  580.     for ($ii = 0; $ii < size($selClips); $ii += 2) {
  581.         int $cindex = $selClips[$ii+1];
  582.         string $sch = $selClips[$ii];
  583.         string $clipName = `clipSchedule -ci $cindex -q -n $sch`;
  584.         string $ch[] = `listConnections -type character $sch`;
  585.         if ($ii == 0) {
  586.             $absState = `getAttr ($clipName+".offset")`;
  587.             $enableState = `clipSchedule -ci $cindex -q -en $sch`;
  588.             if (size($ch)) {
  589.                 string $activeClip = `clip -q -active $ch[0]`;
  590.                 string $sourceClip = `clip -q -scn $clipName`;
  591.                 $activeState = ($activeClip == $sourceClip);
  592.             }
  593.         } else {
  594.             if ($enableState != `clipSchedule -ci $cindex -q -en $sch`) {
  595.                 $enableState = 2;
  596.             }
  597.             if ($absState != `getAttr ($clipName+".offset")`) {
  598.                 $absState = 2;
  599.             }
  600.             if (size($ch)) {
  601.                 string $activeClip = `clip -q -active $ch[0]`;
  602.                 string $sourceClip = `clip -q -scn $clipName`;                
  603.                 int $currActive = ($activeClip == $sourceClip);
  604.                 if ($activeState != $currActive) {
  605.                     $activeState = 2;
  606.                 }
  607.             }
  608.         }
  609.     }
  610.  
  611.     string $toggleEnableCmd = "doEnableClipArgList 1 { \""+
  612.         $editor+"\",\"2\"}";
  613.     menuItem -label "Enable Clip"
  614.         -cb $enableState
  615.         -en ($enableState != 2)
  616.         -annotation "Enable/Disable Selected Clip(s)"
  617.         -command $toggleEnableCmd
  618.         -dragMenuCommand $toggleEnableCmd
  619.         toggleEnableClipItem;
  620.  
  621.     string $toggleOffsetCmd = "toggleClipOffset 1 { \""+
  622.         $editor+"\",\"2\"}";
  623.     menuItem -label "Relative Clip"
  624.         -cb ($absState == 0)
  625.         -en ($absState != 2)
  626.         -annotation "Make Clip Absolute or Relative"
  627.         -command $toggleOffsetCmd
  628.         -dragMenuCommand $toggleOffsetCmd
  629.         toggleOffsetClipItem;
  630.  
  631.     string $activateCmd = "doActivateClipArgList 1 { \""+
  632.         $editor+"\",\"2\"}";
  633.     menuItem -label "Activate Keys"
  634.         -cb $activeState
  635.         -en ($activeState != 2)
  636.         -annotation "Activate or Deactivate Clip Keys (Move Keys to Timeline): Select clip"        
  637.         -command $activateCmd
  638.         -dragMenuCommand $activateCmd
  639.         activateClipItem;
  640.  
  641.     menuItem -divider true;
  642.  
  643.     string $removeCmd = "doCutClipArgList 1 { \""+ $editor+"\" }";
  644.     menuItem -label "Cut Clip"
  645.         -annotation "Cut Clip"
  646.         -command $removeCmd
  647.         -dragMenuCommand $removeCmd;
  648.  
  649.     string $copyCmd = "doCopyClipArgList 1 { \""+ $editor+"\" }";
  650.     menuItem -label "Copy Clip"
  651.         -annotation "Copy Clip"
  652.         -command $copyCmd
  653.         -dragMenuCommand $copyCmd;
  654.  
  655.     string $splitString = ("doSplitClipArgList 1 {\"currTimeMethod\",\"0\",\""+$editor+"\"}");    
  656.     string $splitCmd = $splitString ; // ("evalEcho(\""+$splitString+"\")");
  657.     menuItem -label "Split Clip"
  658.         -annotation "Split Clip: Select clip"
  659.         -command $splitCmd;
  660.     
  661.     menuItem -divider true;
  662.  
  663.     menuItem -label "Attribute Editor..."
  664.         -annotation "Attribute Editor: Edit Clip"
  665.         -command ("clipPropertiesWindow "+$editor)
  666.         -dragMenuCommand ("clipPropertiesWindow "+$editor)
  667.         clipPropItem;
  668.  
  669.     menuItem -divider true;
  670.  
  671.     menuItem -label "Create Time Warp"
  672.         -annotation "Create Time Warp"
  673.         -command ("performCreateClipTimeWarp 0 " + $editor)
  674.         -dragMenuCommand("performBlendClip 2 " + $editor)
  675.         clipTimeWarpItem;
  676.  
  677.     menuItem -label "Blend Clips"
  678.         -annotation "Blend Clips: select two clips"
  679.         -command ("performBlendClip 0 " + $editor)
  680.         -dragMenuCommand("performBlendClip 2 " + $editor)
  681.         -en (size($selClips) == 4)
  682.         blendClipsItem;
  683.  
  684.     menuItem -divider true;
  685.     
  686.     menuItem -label "Select Source Clip"
  687.         -annotation "Select the related source clip for this clip"
  688.         -command ("selectSourceClip "+$editor) ;
  689. }
  690.  
  691. //
  692. // query if clip is in selection list
  693. //
  694. proc int isClipSelected( string $clipEditor, string $clip[] )
  695. {
  696.     string $selectedClips[] = `clipEditor -q -sc $clipEditor`;
  697.     int $numClips = size($selectedClips);
  698.     int $i;
  699.     for ($i=0; $i < $numClips; $i+=2)
  700.     {
  701.         if ( $clip[0] == $selectedClips[$i] && 
  702.              $clip[1] == $selectedClips[$i+1] )
  703.             return 1;
  704.     }
  705.     return 0;
  706. }
  707.  
  708. //
  709. // verify highlighted clip is in selection; if not select it.
  710. //
  711. proc selectHighlightedClip( string $clipEditor )
  712. {
  713.     string $hlClip[] = `clipEditor -q -hc $clipEditor`;
  714.  
  715.     if ($hlClip[0] != "")
  716.     {
  717.         if (!isClipSelected( $clipEditor, $hlClip ))
  718.         {
  719.             clipEditor -edit -deselectAll $clipEditor;
  720.             clipEditor -edit -selectClip $hlClip[0] $hlClip[1] $clipEditor;
  721.         }
  722.     }
  723. }
  724.  
  725.  
  726. global proc buildClipEditorMenuItems(string $editor, string $menu, string $collectionName)
  727. {
  728.     if (`popupMenu -e -exists $menu`) 
  729.     {
  730.         // check if  mouse over a context-sensitive object
  731.         //
  732.         string $menuContext[] = `clipEditor -query -menuContext $editor`;    
  733.  
  734.         // yes, it is. check what type of object it is
  735.         //
  736.         popupMenu -e -deleteAllItems $menu;
  737.  
  738.         if ($menuContext[0] == "clip")
  739.         {
  740.             selectHighlightedClip( $editor );
  741.             buildClipMenuItems( $editor, $menu );
  742.         }
  743.         else {
  744.             popupMenu -e -deleteAllItems $menu;
  745.             buildClipMainPopupMenuItems($editor, $menu, $collectionName);
  746.         }
  747.     
  748.     }
  749. }
  750.  
  751.  
  752. //
  753. // Attach commands to toolbar buttons
  754. //
  755. proc defineButtonCommands (string $editor)
  756. {
  757.     int $dimWhenNoSelect = 0;
  758.  
  759.     iconTextButton -edit -command ("CreateClip") 
  760.         createClipButton;
  761.     iconTextButton -edit -command ("performBlendClip 0 " + $editor)
  762.         createBlendButton;
  763.     iconTextButton -edit -command ("VisorWindow")
  764.         openVisorButton;
  765.  
  766.     iconTextButton -edit -command ("FrameAll")
  767.         frameAllButton;
  768.  
  769.     iconTextButton -edit -command ("frameTimelineRange " + $editor)
  770.         frameRangeButton;
  771.  
  772.     iconTextButton -edit -command ("clipGraphEditor " + $editor)
  773.         graphAnimCurvesButton;
  774. }
  775.  
  776.  
  777. global proc ClipEdMenu(string $editor) 
  778. {
  779.  
  780.     // Find the name of the control that the menu will be attached to
  781.     //
  782.     string $parent = `clipEditor -query -control $editor`;
  783.     string $popupMenuName = ($editor + "PopupMenu");
  784.     string $collectionNameMenu = "Menu";
  785.     string $collectionNamePopup = "Popup";
  786.  
  787.     // Create the popup menu
  788.     //    
  789.     if (!`popupMenu -exists $popupMenuName`)
  790.     {
  791.         string $fullMenuName = `popupMenu -parent $parent $popupMenuName`;
  792.         popupMenu -e
  793.             -parent $parent 
  794.             -pmc ("buildClipEditorMenuItems " + $editor + " " + $fullMenuName + " " + 
  795.                   $collectionNamePopup)
  796.             $popupMenuName;    
  797.     }
  798.     
  799.     buildClipEditorMenu $editor "ClipEditorMenu" $collectionNameMenu;
  800.     defineButtonCommands($editor);
  801. }
  802.  
  803. //
  804. // This method is called from the clipEditor command when the track
  805. // height of the editor changes.
  806. //
  807. global proc setClipEdTrackHeight(int $height)
  808. {
  809.     // If the height is not 1 or 2, just return.
  810.     if (($height != 1) && ($height != 2))
  811.         return;
  812.  
  813.     // Set the optionVar to the height.
  814.     optionVar -intValue traxEditorTrackHeight $height;
  815.     
  816.     int $radioSmallValue = 1;
  817.     int $radioLargeValue = 0;
  818.     
  819.     if (`optionVar -q traxEditorTrackHeight` == 2) {
  820.         $radioSmallValue = 0;
  821.         $radioLargeValue = 1;
  822.     }
  823.     
  824.     // Look for all menu itmems which are track height radios and set their
  825.     // button values.
  826.     string $items[] = `lsUI -ed`;
  827.     for ($pitem in $items) {
  828.         string $regExpr = "clipEditorPanel.*ClipEditor";
  829.         string $s = match($regExpr, $pitem);
  830.         if (`strcmp $s $pitem` == 0) {
  831.             string $popupMenuName = ($pitem + "PopupMenu");
  832.             if (`popupMenu -exists $popupMenuName`) {
  833.                 string $radioSmallStr = ($pitem + "TraxRadioSmallName");
  834.                 string $radioLargeStr = ($pitem + "TraxRadioLargeName");
  835.                 menuItem -e -rb $radioSmallValue $radioSmallStr;
  836.                 menuItem -e -rb $radioLargeValue $radioLargeStr;
  837.             }
  838.         }
  839.     }
  840. }
  841.  
  842.  
  843. //
  844. //  Procedure Name:
  845. //      createClipLibraryMenu
  846. //
  847. //  Description:
  848. //        Create the menu that lists source clips from the clipLibrary
  849. //
  850. //  Input Arguments:
  851. //      $parent - parent menu
  852. //
  853. //  Return Value:
  854. //      None
  855. //
  856. global proc createClipLibraryMenu( string $type, string $parent ) {
  857.     setParent -m $parent;
  858.     menu -e -dai $parent;
  859.  
  860.     source addVisorFolders;
  861.     source hypergraphAnimClipMenu;
  862.     
  863.     // Get clips on current character
  864.     //
  865.     string $charClips[];
  866.     string $unusedClips[];
  867.     string $currChars[] = `currentCharacters`;
  868.     if ($type == "pose") {
  869.         $charClips = `getAllCharacterPoses`;
  870.         $unusedClips = `getLibraryPoses`;
  871.     } else {
  872.         $charClips = `getAllCharacterClips`;
  873.         $unusedClips = `getLibraryClips`;
  874.     }
  875.     int $total = size($charClips) + size($unusedClips);
  876.  
  877.     if( $total == 0 ) {
  878.         menuItem -l ("No "+$type+"s on current character set") -enable false;
  879.     } else {
  880.         string $cmd;
  881.         string $annotation;
  882.         string $clipName;
  883.         for( $clipName in $charClips ) {
  884.             $annotation = ( "Insert " + $clipName );
  885.             $cmd = ("clipInstanceMenuCommand "+$clipName);
  886.             menuItem -l $clipName -c $cmd -annotation $annotation;
  887.         }
  888.         if (size($unusedClips)) {
  889.             menuItem -divider true;
  890.             for( $clipName in $unusedClips ) {
  891.                 $cmd = ( "clip -copy " + $clipName + "; doPasteClipArgList 2 { \"byAttrName\", \"currentTime\" }" );
  892.                 $annotation = ( "Insert " + $clipName );
  893.                 menuItem -l $clipName -c $cmd -annotation $annotation;
  894.             }
  895.         }
  896.     }
  897. }
  898.